package com.cjjd.c.feature.mine.Integral;

import android.support.v4.app.FragmentActivity;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.cjjd.c.R;
import com.cjjd.c.base.MyBaseAdapter;
import com.cjjd.c.bean.IntegralItemBean;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * ----------------------------------
 * Created by xyd on 2017/8/15.
 * <p/>
 * 描  述：
 * <p/>
 * 修订历史:
 * ----------------------------------
 */

public class IntegralAdapter extends MyBaseAdapter {
    public IntegralAdapter(FragmentActivity mContext) {
        super(mContext);
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        ViewHolder viewHolder = null;
        if (convertView == null) {
            convertView = LayoutInflater.from(mContext).inflate(R.layout.item_integral, parent, false);
            viewHolder = new ViewHolder(convertView);
            convertView.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) convertView.getTag();
        }

        IntegralItemBean item = (IntegralItemBean) getItem(position);

        viewHolder.tvReason.setText(item.typeName);
        viewHolder.tvPoint.setText("+"+item.intergralCount);
        viewHolder.tvTime.setText(item.createTime.substring(0,10));
        if (!TextUtils.isEmpty(item.overdueTime)){
            //viewHolder.tvEndTime.setText("有效期至 "+item.overdueTime.substring(0,10));
        }


        return convertView;
    }

    static class ViewHolder {
        @Bind(R.id.tv_reason)
        TextView tvReason;
        @Bind(R.id.tv_time)
        TextView tvTime;
        @Bind(R.id.tv_point)
        TextView tvPoint;
//        @Bind(R.id.tv_end_time)
//        TextView tvEndTime;

        ViewHolder(View view) {
            ButterKnife.bind(this, view);
        }
    }
}
